/**********************************************************************************
**
** Copyright (C) 2010 Jostein Bratlie
** Contact: jostein.bratlie@gmail.com | http://bratlie.info | http://episteme.hin.no
**
** This file is part of GMQtExt, a GMlib and Qt extension library
**
** GMQtExt is free software: you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** GMQtExt is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public License
** along with GMQtExt.  If not, see <http://www.gnu.org/licenses/>.
**
**********************************************************************************/


// GMlib
#include <gmGlobal>


// Header
#include "messageboxes.h"

namespace GMQtExt {

  void MessageBoxes::aboutGMlib( QWidget* parent, const QString& title ) {

    #ifdef Q_WS_MAC
      static QPointer<QMessageBox> oldMsgBox;

      if (oldMsgBox) {
        oldMsgBox->show();
        oldMsgBox->raise();
        oldMsgBox->activateWindow();
        return;
      }
    #endif

    QString translatedTextAboutGMlibCaption;
    translatedTextAboutGMlibCaption = QMessageBox::tr(
      "<h3>About GMlib</h3>"
      "<p>This program uses GMlib version %1.</p>"
    ).arg(QLatin1String(GM_VERSION_STR));

    QString translatedTextAboutGMlibText;
    translatedTextAboutGMlibText = QMessageBox::tr(
      "<p>GMlib is an open source Geometric Modeling library.</p>"
      "<p>GMlib is written in C++ and uses mainly OpenGL for rendering.</p>"

      "<p>GMlib is available under the GNU Lesser General Public License version 3 or later.</p>"
      "<p>Copyright (C) 1994 2010 Narvik University College.</p>"
      "<p>See <a href=\"http://episteme.hin.no/\">episteme.hin.no</a> for more information.</p>"
    );

    QMessageBox *msgBox = new QMessageBox(parent);
    msgBox->setAttribute(Qt::WA_DeleteOnClose);
    msgBox->setWindowTitle(title.isEmpty() ? tr("About GMlib") : title);
    msgBox->setText(translatedTextAboutGMlibCaption);
    msgBox->setInformativeText(translatedTextAboutGMlibText);

      // should perhaps be a style hint
    #ifdef Q_WS_MAC
      oldMsgBox = msgBox;
    #if 0
      // ### doesn't work until close button is enabled in title bar
      msgBox->d_func()->autoAddOkButton = false;
    #else
      msgBox->d_func()->buttonBox->setCenterButtons(true);
    #endif
      msgBox->show();
    #else
      msgBox->exec();
    #endif
  }

} // END namespace GMQtExt





